import MySQLdb,datetime,struct,hashlib

WEISHU=29
SEG=13
SEG_OFFSET=11
OFFSET_VALUE=5
def get_full_md5(url):
    m=hashlib.md5()
    m.update(url)
    b_m=m.digest()
    return b_m
def md52int(b_m,weishu=WEISHU):
    b_length=len(b_m)
    l_m=0L
    for i in xrange(b_length):
        b_quan=2**(8*i)
        b_int=struct.unpack('B',b_m[i])[0]
        l_m+=b_int*b_quan
    return l_m%(2**weishu)
def get_md52int(url):
    return md52int(get_full_md5(url))

print get_md52int('http://csdnimg.cn/www/css/main_new.css?201207271657')




